using System.Windows;
using System.Windows.Media;
using System.Windows.Controls;

namespace GraphMyCode.Controls
{
	public abstract class GraphItemDescriptor : FrameworkElement
	{

		public static readonly DependencyProperty ItemProperty =
			DependencyProperty.Register("Item", typeof(GraphItem), typeof(GraphItemDescriptor), null);

		public static readonly DependencyProperty ShapeProperty =
			DependencyProperty.Register("Shape", typeof(Geometry), typeof(GraphItemDescriptor), null);


		//NOTE: DependencyProperty ???
		public GraphItem Item
		{
			get { return (GraphItem)GetValue(ItemProperty); }
			set { SetValue(ItemProperty, value); }
		}

		internal abstract double Left
		{
			get;
		}

		internal abstract double Top
		{
			get;
		}

		internal abstract int ZIndex
		{
			get;
		}

		public Geometry Shape
		{
			get { return (Geometry)GetValue(ShapeProperty); }
			set { SetValue(ShapeProperty, value); }
		}

		internal virtual void UpdatePosition()
		{
			Canvas.SetZIndex(Item, ZIndex);

			Item.RenderTransform = new TranslateTransform { X = Left, Y = Top };
			Item.Bounds.X = Left;
			Item.Bounds.Y = Top;
		}
	}
}